from django.db import models as m

from course_app.models import Course,Stage
# Create your models here.
class Update(m.Model):
    UPDATE_TYPE=(
        (0,'升级'),
        (1,'新增')
    )
    '''更新课程信息'''
    name = m.CharField(max_length=255,verbose_name='更新的课程标题')
    introduction = m.TextField(blank=True,null=True,verbose_name='介绍')
    info = m.TextField(blank=True,null=True,verbose_name='课程信息')
    create_time = m.DateTimeField(blank=True,null=True,auto_now_add=True,verbose_name='创建时间')
    update_type = m.IntegerField(blank=True,null=True,choices=UPDATE_TYPE,verbose_name='更新类型')

    course = m.ForeignKey(Course,related_name='update',on_delete=m.SET_NULL,verbose_name='课程',blank=True,null=True)
    stage = m.ForeignKey(Stage,related_name='update',on_delete=m.SET_NULL,verbose_name='阶段',blank=True,null=True)

    class Meta:
        db_table = 't_update_course'
